package main.rabbitmqProvider.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicModelConfig {
    public static final String TOPIC_EXCHANGE_NAME = "topic_exchange_name";

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(TOPIC_EXCHANGE_NAME);
    }

    //声明队列
    @Bean
    public Queue topicQueue1() {
        return new Queue("topic_queue1");
    }

    @Bean
    public Queue topicQueue2() {
        return new Queue("topic_queue2");
    }

    @Bean
    public Queue topicQueue3() {
        return new Queue("topic_queue3");
    }

    //绑定队列到交换机

    @Bean
    public Binding TopicBinding1() {
        return BindingBuilder.bind(topicQueue1()).to(topicExchange()).with("*.orange.*");
    }

    @Bean
    public Binding TopicBinding2() {
        return BindingBuilder.bind(topicQueue2()).to(topicExchange()).with("*.*.rabbit");
    }

    @Bean
    public Binding TopicBinding3() {
        return BindingBuilder.bind(topicQueue3()).to(topicExchange()).with("lazy.#");
    }
}
